public class PloProgram {

	private Declarations decSeq;
	private Statements stmtSeq;
	
	public PloProgram(Tokens tokens){
		this.parseProgram(tokens);
	}
	
	public void parseProgram(Tokens tokens){
		tokens.skipToken();
		if(tokens.getToken() != 1){
			System.err.println("instruction must being with keyword \"program\"");
			System.exit(0);
		}
		tokens.skipToken();
		this.decSeq = new Declarations(tokens);
		if(tokens.getToken() != 2){
			System.err.println("instruction must being with keyword \"begins\"");
			System.exit(0);
		}
		tokens.skipToken();
		this.stmtSeq = new Statements(tokens);
		if(tokens.getToken() != 3){
			System.err.println("instruction must end with keyword \"end\"");
			System.exit(0);
		}
	}

	/**
	 * Executes the program.
	 */
	public void runProgram() {
		stmtSeq.runStmtSeq();
	}
}